from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver_path = Service(executable_path='./chromedriver.exe')
options = Options()
options.add_experimental_option("detach", True)
browser = webdriver.Chrome(service=driver_path, options=options)

browser.get('https://www.baidu.com')
wait = WebDriverWait(browser, 5) # 5s内没有加载出来就抛异常
ipt = wait.until(EC.presence_of_element_located((By.ID, 'kw')))
btn = wait.until(EC.element_to_be_clickable((By.ID, 'su')))

print(ipt, btn)
